/**
 * @properties={typeid:35,uuid:"0BE81BD0-6145-49B0-BF83-3E89F87C48EA",variableType:93}
 */
var fFechaDesde = null;

/**
 * @properties={typeid:35,uuid:"7F01D76D-94F4-4371-B978-E8B8BE3199A4",variableType:93}
 */
var fFechaHasta = null;

/**
 * @properties={typeid:35,uuid:"22EAD44D-FBE9-48AD-AADA-DBBCED1DF40A",variableType:4}
 */
var fFletero = null;

/**
 * Perform the element default action.
 *
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"61D9223C-7A27-424B-B2E1-6EAEE2C18207"}
 */
function mostrarTodos(event) 
{
	controller.loadAllRecords()
}

/**
 * Perform the element default action.
 *
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"D90517FE-4E69-4592-A09E-69097022FF0A"}
 */
function buscar(event) 
{	
	controller.find()
	
	proveedor_id = fFletero
	if(fFechaDesde != null && fFechaHasta != null)
	{
		var SearchDate = new Date()
		SearchDate = '#'+utils.dateFormat(fFechaDesde,'dd-MM-yyyy')+'...'+utils.dateFormat(fFechaHasta,'dd-MM-yyyy')
		fecha = SearchDate +'|dd-MM-yyyy'
	}
	if (controller.search() == 0)
		globals.gDialog('Error','No se encontraron resultados','OK','CerrarForm')
}

/**
 * Perform the element default action.
 *
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"5BFB260C-8B9C-4075-B3A1-29758E7171D1"}
 */
function anular(event) 
{
	fFechaDesde = null
	fFechaHasta = null
}

/**
 * Callback method for when form is shown.
 *
 * @param {Boolean} firstShow form is shown first time after load
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"4F50285B-A34D-48E9-8068-F53D5284A384"}
 */
function inicio(firstShow, event) 
{
	fFechaHasta= new Date();
	fFechaDesde= new Date();
	fFechaDesde=fFechaDesde.setDate(fFechaHasta.getDate() - 300);
	fFletero=forms.liq_ncyd_viajes.proveedor_id;
	buscar();    
}

/**
 * Perform the element default action.
 *
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"0C82B1A0-5D75-4B48-A703-1F4C09B47ADA"}
 */
function confirmar(event) 
{
	
	forms.liq_ncyd_viajes.liq_cabecera_to_liq_detalle.deleteAllRecords();
	for (var i=1;i <= forms.liq_ncyd_viajes_4.controller.getMaxRecordIndex() ;i++)
	{
		forms.liq_ncyd_viajes_4.controller.setSelectedIndex(i);
		if (forms.liq_ncyd_viajes_4.marcado_liq_detalle==1)
		{
			forms.liq_ncyd_viajes.liq_cabecera_to_liq_detalle.newRecord();
			forms.liq_ncyd_viajes.liq_cabecera_to_liq_detalle.viaje_id=forms.liq_ncyd_viajes_4.viaje_id;
			forms.liq_ncyd_viajes.liq_cabecera_to_liq_detalle.neto=forms.liq_ncyd_viajes_4.neto;
			forms.liq_ncyd_viajes.liq_cabecera_to_liq_detalle.tarifa=forms.liq_ncyd_viajes_4.tarifa;
			forms.liq_ncyd_viajes.liq_cabecera_to_liq_detalle.importe=forms.liq_ncyd_viajes_4.importe;
			forms.liq_ncyd_viajes.liq_cabecera_to_liq_detalle.observaciones=forms.liq_ncyd_viajes_4.observaciones;
			forms.liq_ncyd_viajes.liq_cabecera_to_liq_detalle.tarifa_referencia=forms.liq_ncyd_viajes_4.tarifa;   // 16/04/2012
			forms.liq_ncyd_viajes.liq_cabecera_to_liq_detalle.importe_referencia=forms.liq_ncyd_viajes_4.importe; // 16/04/2012
			
		}
	}
	globals.gcancela=0;  //  se usa al final ??   o no?
	application.closeForm('ver_liquidacion');
}

/**
 * Perform the element default action.
 *
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"807718BC-5503-416C-BB0D-F2A1559AA86A"}
 */
function cancela(event) 
{
	globals.gcancela=1;
	//  si se cancela, desmarcar antes de volver  
	for (var i=1;i <= forms.liq_ncyd_viajes_4.controller.getMaxRecordIndex() ;i++)
	{
		forms.liq_ncyd_viajes_4.controller.setSelectedIndex(i);
		if (forms.liq_ncyd_viajes_4.marcado_liq_detalle==1)
			forms.liq_ncyd_viajes_4.marcado_liq_detalle=0;
	}
	//application.closeForm('ira_liq_ncyd_viajes_4');
	application.closeForm('ver_liquidacion');
}
